//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Spreadsheet.Expressions;

namespace OpenLS.Spreadsheet.Parsing
{
    internal class UnqualifiedRangeIntersectionExpression : UnqualifiedCellsAccessExpression
    {
        private readonly UnqualifiedCellsAccessExpression _left;
        private readonly UnqualifiedCellsAccessExpression _right;

        public UnqualifiedRangeIntersectionExpression(UnqualifiedCellsAccessExpression left, UnqualifiedCellsAccessExpression right)
        {
            _left = left;
            _right = right;
        }

        public override CellEnumeratorExpression RangeQualifiedExpression(RangeFactory factory)
        {
            var newLeft = _left.RangeQualifiedExpression(factory);
            var newRight = _right.RangeQualifiedExpression(factory);
            return new RangeIntersectionExpression(newLeft, newRight);
        }
    }
}